package logs

import (
	"encoding/json"
	"github.com/astaxie/beego/logs"
	"log"
)

func Init(cfg *Config) {
	if cfg.Console {
		err := logs.SetLogger(logs.AdapterConsole)
		if err != nil {
			log.Panic(err)
		}
	}
	data, _ := json.Marshal(cfg)
	logs.SetLogFuncCall(true)
	err := logs.SetLogger(logs.AdapterMultiFile, string(data))
	if err != nil {
		log.Panic(err)
	}
}
